package com.mcxx.modules.miniSalvation.family.service.write;

import com.mcxx.common.exception.BizException;
import com.mcxx.modules.miniSalvation.family.entity.FamilyMemberTempEntity;
import com.mcxx.modules.miniSalvation.family.dao.write.FamilyMemberTempWriteDao;
import com.mcxx.util.FailureCode;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@TaTransactional
public class FamilyMemberTempWriteService {

    @Autowired
    private FamilyMemberTempWriteDao familyMemberTempWriteDao;



    public int saveFamilyMemberTemp(FamilyMemberTempEntity familyMemberTemp) {
    	return familyMemberTempWriteDao.insert(familyMemberTemp);
    }


    public int insertIgnoreNull(FamilyMemberTempEntity familyMemberTemp) {
    	return familyMemberTempWriteDao.insertIgnoreNull(familyMemberTemp);
    }


    public int update(FamilyMemberTempEntity familyMemberTemp) {
    	return familyMemberTempWriteDao.update(familyMemberTemp);
    }


    public int updateIgnoreNull(FamilyMemberTempEntity familyMemberTemp) {
    	return familyMemberTempWriteDao.updateIgnoreNull(familyMemberTemp);
    }


    public int delete(FamilyMemberTempEntity familyMemberTemp) {
    	return familyMemberTempWriteDao.delete(familyMemberTemp);
    }


    public void saveBatchFamilyMemberTemp(List<FamilyMemberTempEntity> familyMemberTempList) {
        int rows = familyMemberTempWriteDao.insertBatchIgnoreNull(familyMemberTempList);
        if (rows < familyMemberTempList.size()) {
            throw new BizException(FailureCode.ERR_9999);
        }
    }
}
